Skip to content

Conversation

@bergundy
Copy link
Member

What was changed

  • Added support for ScheduleToStartTimeout and StartToCloseTimeout for Nexus operations in the Java SDK and test server.
  • In the test server:
    • Cap secondary timeouts to scheduleToClose timeout
    • Support all three timeout types in timeoutNexusOperation()
    • Calculate OPERATION_TIMEOUT header dynamically in pollNexusTaskQueue() and use the correct header format
  • Added tests for the new functionality

NOTE: Do not merge until the API is tagged.

@bergundy bergundy requested a review from a team as a code owner January 14, 2026 00:57
@Quinn-With-Two-Ns
Copy link
Contributor

Can we add some tests like we have for activity

to verify the parameter is properly wired through and respected

@bergundy
Copy link
Member Author

Can we add some tests like we have for activity

to verify the parameter is properly wired through and respected

We have coverage in NexusWorkflowTest.java.

Assert.assertTrue("OPERATION_TIMEOUT should be positive", operationTimeoutMs > 0);

// Sleep longer than schedule-to-start timeout to trigger the timeout
Thread.sleep(2000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to use testWorkflowRule.sleep here to avoid waiting real time in the time skipping test server, but I would prefer the test not use a sleep and just wait for the condition to be true. Should be possible to wait for the operation to fail by looking at the workflow describe output no?

@Quinn-With-Two-Ns
Copy link
Contributor

We have coverage in NexusWorkflowTest.java.

NexusWorkflowTest.java doesn't use the Java SDK so it is not providing coverage of the SDK

@Quinn-With-Two-Ns
Copy link
Contributor

Quinn-With-Two-Ns commented Jan 14, 2026

you also need to update constructPendingNexusOperationInfo in the test server I think, unless I missed that.

Copy link
Contributor

@maciejdudko maciejdudko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments about timeout calculation in test server but otherwise looks good.

Comment on lines 981 to 982
long elapsedSeconds = Timestamps.between(scheduledTime, currentTime).getSeconds();
long elapsedMillis = elapsedSeconds * 1000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rounds off milliseconds from the difference. At the extreme, a sub-second timeout will be rounded to zero.

Suggested change
long elapsedSeconds = Timestamps.between(scheduledTime, currentTime).getSeconds();
long elapsedMillis = elapsedSeconds * 1000;
long elapsedMillis = com.google.protobuf.util.Durations.toMillis(
Timestamps.between(scheduledTime, currentTime));

// Calculate minimum of all applicable timeouts
Long remainingMillis = null;

if (!isStarted && scheduledEvent.hasScheduleToStartTimeout()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ScheduleToStartTimeout should not be part of the calculation here.

com.google.protobuf.util.Durations.toMillis(
scheduledEvent.getScheduleToCloseTimeout());
if (scheduleToCloseMillis > 0) {
long remaining = scheduleToCloseMillis - elapsedMillis;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should handle the situation where elapsedMillis is larger than scheduleToCloseMillis for some reason, just for extra safety.

Suggested change
long remaining = scheduleToCloseMillis - elapsedMillis;
long remaining = Math.max(1, scheduleToCloseMillis - elapsedMillis);

Comment on lines 1002 to 1004
long remaining = startToCloseMillis - elapsedMillis;
remainingMillis =
(remainingMillis == null) ? remaining : Math.min(remainingMillis, remaining);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StartToCloseTimeout should not have elapsed time subtracted.

Suggested change
long remaining = startToCloseMillis - elapsedMillis;
remainingMillis =
(remainingMillis == null) ? remaining : Math.min(remainingMillis, remaining);
remainingMillis =
(remainingMillis == null) ? startToCloseMillis : Math.min(remainingMillis, startToCloseMillis);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants